package com.ruoyi.web.controller.system;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.enums.BusinessStatus;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.MerchantFeedback;
import com.ruoyi.system.service.IMerchantFeedbackService;

/**
 * 招商咨询Controller
 * 
 * @author ruoyi
 */
@Controller
@RequestMapping("/info")
public class BussinessController extends BaseController
{
	
	@Autowired
	IMerchantFeedbackService merchantFeedbackService;
    @GetMapping("/1")
    public String login(HttpServletRequest request, HttpServletResponse response)
    {

        return "bussinessPage/html/aqms";
    }
    @GetMapping("/2")
    public String ldgn(HttpServletRequest request, HttpServletResponse response)
    {

        return "bussinessPage/html/ldgn";
    }
    @GetMapping("/3")
    public String msyl(HttpServletRequest request, HttpServletResponse response)
    {

        return "bussinessPage/html/msyl";
    }
    
    @GetMapping("/4")
    public String wyjs(HttpServletRequest request, HttpServletResponse response)
    {

        return "bussinessPage/html/wyjs";
    }
    
    @PostMapping("/consulting")
    @ResponseBody
    public Map<String, Object> consulting(MerchantFeedback merchantFeedback)
    {
    	merchantFeedback.setId(StringUtils.randomUUID());
    	merchantFeedback.setCreateTime(new Date());
    	merchantFeedback.setStatus("3");//表示招商咨询
    	int insertMerchantFeedback = merchantFeedbackService.insertMerchantFeedback(merchantFeedback);
    	Map<String, Object> map = new HashMap<>();
    	if (insertMerchantFeedback>0) {
    		map.put("status", BusinessStatus.SUCCESS);
    		map.put("msg", "提交成功，请耐心等待市场经理的回电");
		} else {
			map.put("status", BusinessStatus.FAIL);
    		map.put("msg", "网络故障，请稍后重试");
		}
        return map;
    }
}
